package edu.sdibt;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class ConnectionTest {
	public static void main(String[] args) {
		String url="jdbc:oracle:thin:@localhost:1521:orcl";
		Connection connection=null;
		String sql = "select * from users"; 
			try{
				Class.forName("oracle.jdbc.driver.OracleDriver");
				connection=DriverManager.getConnection(url, "testdb","testdb");
				PreparedStatement pst = connection.prepareStatement(sql);
				ResultSet rs= pst.executeQuery();
				while(rs.next()) {
					System.out.print(rs.getInt(1)+",");
					System.out.print(rs.getString(2)+",");
					System.out.print(rs.getString(3)+",");
					System.out.print(rs.getString(4));
					System.out.println();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			System.out.println();
			
		}
		

}
